# -*- coding: utf-8 -*-
# @Date    : 2017-05-26 16:59:11
# @Author  : fancy (fancy@thecover.co)

from time import ctime
from SocketServer import (TCPServer as TCP,
    StreamRequestHandler as SRH)


HOST = ''
PORT = 8888
ADDR = (HOST, PORT)


class MyRequestHandler(SRH):

    def handle(self):
        print '...conneted from: ', self.client_address
        self.wfile.write('[%s] %s' % (ctime(), self.rfile.readline()))


tcp_server = TCP(ADDR, MyRequestHandler)
print 'waiting for connection...'
tcp_server.serve_forever()
